#自动取款机的存取款模拟效果
userlist=[
{'name':'张三','money':20000,'password':'112233','card id':'001'},
{'name':'李四','money':40000,'password':'223344','card id':'002'},
{'name':'王五','money':60000,'password':'334455','card id':'003'}
]

#定义一个账号信息的输出函数
def showuser(userlist):
    print('| {:<10}| {:<10}|'.format(userlist[i]['name'],userlist[i]['money']))


while True:
    #输出登陆界面
        print('='*14,'交通银行欢迎你','='*14)
        myid = input('请输入用户名： ')
        i=0
        while i<4:
                if myid == userlist[i]['name']:
                        mypassword = input('请输入密码： ')
                        if mypassword != userlist[i]['password']:
                            print('密码错误 ')
                            break
                        elif mypassword == userlist[i]['password']:
                            print('登陆成功 ')
                            while True:
                            #输出操作界面
                                print('{0:2} {1:12} {2:15}'.format(' ', '1.查询余额', '2.存款'))
                                print('{0:2} {1:13} {2:15}'.format(' ', '3.取款', '4.退出系统'))
                                print('=' * 42)
                                key = input('请输入对应的选择： ')
                                #根据键盘值，判断并执行对应的操作
                                if key == '1':
                                    print('='*12,'查询余额','='*14)
                                    showuser(userlist)
                                    input('按回车键返回操作界面： ')
                                elif key == '2':
                                    print('=' * 12, '存款', '=' * 14)
                                    amount = input('请输入存入金额： ')
                                    userlist[i]['money']= userlist[i]['money']+int(amount)
                                    input('按回车键返回操作界面： ')
                                    print('='*40)
                                elif key == '3':
                                    print('='*12,'取款','='*14)
                                    withdrawal = input('请输入取款金额： ')
                                    if int(withdrawal) > userlist[i]['money']:
                                        print('余额不足！')
                                    else:
                                        int(withdrawal) > userlist[i]['money']-int(withdrawal)
                                        input('按回车键返回操作界面： ')
                                        print('='* 42)
                                elif key == '4':
                                        print('='*12,'再见','='*14)
                                        break
                                else:
                                    print('============ 无效的键盘输入 ============')

                else:i+=1
        else:
            print('欢迎再来！')






